import { request } from '@/utils/request'

export interface ContributionModel {
  list: {
    tlist: {
      [tid: string]: {
        tid: number //分区tid
        count: number //分区内容个数
        name: string //分区名
      }
    }
    vlist: {
      comment: number //评论数
      typeid: number //稿件所在视频分区id
      play: number //播放量
      pic: string
      description: string //稿件描述内容
      title: string //稿件标题
      author: string //作者名
      mid: number //作者的mid也就是uid
      created: number //投稿时间戳
      length: '04:30'
      video_review: number //弹幕数
      aid: number
      bvid: string
      is_union_video: 1 | 0 //是否为合作视频 1为肯定
    }[]
  }
  page: {
    pn: number
    ps: number
    count: number
  }
}

export type OrderType = 'pubdate' | 'click' | 'stow'

/* 
order参数
默认为pubdate
最新发布：pubdate
最多播放：click
最多收藏：stow

tid参数，筛选分区
 */
export const reqContribution = (mid: number, pn: number, tid = 0, order: OrderType = 'pubdate') =>
  request<ContributionModel>({
    url: '/space/arc/search',
    params: {
      mid, //目标用户的id
      tid,
      order,
      pn,
      ps: 30,
    },
  })
